<template>
  <div class="form-layout">
    <!--左侧导航-->
    <div class="nav-left">
      <customAnchor
        :itemList="[
          { name: 'box-base', title: '基础信息' },
          { name: 'box-procure', title: '采购信息' },
          { name: 'box-supply', title: '供应商信息' },
          { name: 'box-status', title: '状态信息' },
        ]"
      />
    </div>

    <!--表单区域-->
    <div class="form-right" ref="formRight">
      <customForm :data="form" :rules="propRules" ref="editForm" :disabled="propReadonly">
        <template #content>
          <div id="box-base" class="box-title">基础信息</div>
          <customFormItem label="资产名称" name="assetname" :parent="_self" :form="form" />
          <customFormItem label="资产卡片编号" name="assetcode" :parent="_self" :form="form" />
          <customFormItem label="品牌" name="brand" :parent="_self" :form="form" />
          <customFormItem label="规格型号" name="specmodel" :parent="_self" :form="form" />
          <customFormItem label="单位" name="unit" :parent="_self" :form="form" />
          <customFormItem label="生产厂家名称" name="mfgname" :parent="_self" :form="form" />

          <customFormItem label="资产分类" name="assetclass" :parent="_self" :form="form" readonly="true"
          :showSelectIcon="true"
          @focus="$refs.tableDrawerAssetClass.show()"
          />

          <customFormItem label="院内财务分类" name="financialclass" :parent="_self" :form="form" />
          <customFormItem label="财政国标分类" name="gpcatalog" :parent="_self" :form="form" readonly="true"
          :showSelectIcon="true"
          @focus="$refs.tableDrawerProcClass.show()"
          />
          <customFormItem label="注册证号" name="registcode" :parent="_self" :form="form" />
          <customFormItem label="注册证名称" name="registname" :parent="_self" :form="form" />
          <customFormItem label="产品序列号" name="serialnumber" :parent="_self" :form="form" />
          <customFormItem label="出厂编号" name="productnumber" :parent="_self" :form="form" />
          <customFormItem label="电子定位号" name="elfcode" :parent="_self" :form="form" />
          <customFormItem label="电子标签号" name="rfidcode" :parent="_self" :form="form" />
          <customFormItem label="验收人" name="accepter" :parent="_self" :form="form" />
          <customFormItem label="资金来源" name="fundsource"
          :parent="_self" :form="form"
          :type="constCommon.formItemType.selectDict.name"
          :config="{dictType: constCommon.dictType.fundsSource}"
          />
          <customFormItem label="联系人及电话" name="servicecontact" :parent="_self" :form="form" />
          <customFormItem label="维修人" name="serviceengineer" :parent="_self" :form="form" />
          <customFormItem label="设备编号" name="equipcode" :parent="_self" :form="form" />
          <customFormItem label="医疗设备分类" name="medicalcatalogText" :parent="_self" :form="form" readonly="true"
          :showSelectIcon="true"
          @focus="$refs.tableDrawerMedicalClass.show()"
          />


          <div id="box-procure" class="box-title">采购信息</div>
          <customFormItem label="合同编号" name="contractnumber" :parent="_self" :form="form" />
          <customFormItem label="发票号码" name="invoicenumber" :parent="_self" :form="form" />

          <div id="box-supply" class="box-title">供应商信息</div>
          <customFormItem label="采购来源" name="buysource" :parent="_self" :form="form" />
          <customFormItem label="供应商名称" name="suppliername" :parent="_self" :form="form" />
          <customFormItem label="联系人及电话" name="suppliercontact" :parent="_self" :form="form" />


          <div id="box-status" class="box-title">状态信息</div>
          <customFormItem label="入账标识" name="accountstatus" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="资产状态" name="assetstatus" :parent="_self" :form="form"  :type="constCommon.formItemType.selectDict.name"  :config="{dictType: constCommon.dictType.equipAssetStatus}" />
          <customFormItem label="设备标识" name="equipflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="急救（生命）支持设备标志" name="firstaidflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="大型设备" name="largeflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="中型设备" name="mediumflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="计量标志" name="meteringflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="特种设备标志" name="specialflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="放射（辐射）设备标志" name="radiateflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="科研（科教）设备标志" name="scientificflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="公用平台设备标志" name="publicflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="重点医学装备标志" name="pointsflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="灭菌类设备标志" name="sterilisatioflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>
          <customFormItem label="压力容器类设备标志" name="pressureflag" :parent="_self" :form="form"  :type="constCommon.formItemType.switch.name"/>


        </template>
      </customForm>
    </div>

<!--资产分类选择-->
<tableDrawer ref="tableDrawerAssetClass" refName="tableDrawerAssetClass" @confirm="tableDrawerConfirm" :viewKey="constCommon.viewKeySelect.assetClass"/>
<!-- 财政分类选择 -->
<tableDrawer ref="tableDrawerProcClass" refName="tableDrawerProcClass" @confirm="tableDrawerConfirm" :viewKey="constCommon.viewKeySelect.procClass"/>
<!-- 医疗设备分类选择 -->
<tableDrawer ref="tableDrawerMedicalClass" refName="tableDrawerMedicalClass" @confirm="tableDrawerConfirm" :viewKey="constCommon.viewKeySelect.medicalClass"/>

  </div>
</template>

<script>
import FortenUpload from '@/components/common/FortenUpload.vue'
// import SupplierSelect from '@/components/base/SupplierSelect'
import sunMenu from '@/views/sunMenu/sun_menu.vue'
import customAnchor from '@/components/custom/form/customAnchor.vue'
// import customUpload from '@/components/custom/form/customUpload.vue'

export default {
  data() {
    return {
      form: {},
      viewData: {},
      selectSupplierColumns: [
        { name: 'name', span: 20, search: true  },
        { name: 'namePy', span: 4, search: true  },
      ],
      selectMfgColumns: [
        { name: 'name', span: 20, search: true  },
        { name: 'namePy', span: 4, search: true  },
      ],
      activeNames: ['1', '2', '12', '4', '5', '6'],
      // dialogShow: false //是否显示阳采选择框
    }
  },
  filters: {
    filterImage(data) {
      return `${data}?temp=${Math.random()}`
    }
  },
  methods: {

    // 弹框选择
    tableDrawerConfirm(row, refName) {
      //资产设备分类
      if (refName == 'tableDrawerAssetClass') {
        this.$set(this.form, 'assetclass', row.name)
        return true
      }
      //财政分类
      if (refName == 'tableDrawerProcClass') {
        this.$set(this.form, 'gpcatalog', row.name)
        return true
      }
      //医疗设备分类
      if (refName == 'tableDrawerMedicalClass') {
        this.$set(this.form, 'medicalcatalog', row.id);
        this.$set(this.form, 'medicalcatalogText', row.name);
        return true
      }


    }

  },
  created() {
    this.$emit('event-register', {
      // 表单校验
      validate: (callback) => {
        return this.$refs.editForm.validate(callback)
      },
      // 保存前校验
      beforeSave: () => {
        this.$emit('data-callback', this.form)
        return true
      },

      // 行数据变换后，一般做表单初始化
      afterMove: (formData, initData) => {
        this.form = global.utils.jsonClone(formData)
      },

      // 保存后操作
      afterSave: () => {},

      // 删除前操作
      beforeDelete: () => {
        return true
      },

      // 删除后操作
      afterDelete: () => {},

      // 流程操作前操作
      beforeFlow: (flowButtonKey) => {
        return true
      },
      // 流程操作后操作
      afterFlow: (flowButtonKey) => {},

      // 关闭表单窗口前操作
      beforeClose: () => {
        return true
      },
    })
  },
  props: {
    propParent: Object,
    propInitData: Object,
    propPrimaryKey: String,
    propDictionaries: Object,
    propCurrentRow: Object,
    propViewFormData: Object,
    propReadonly: Boolean,
    propStatus: String,
    propRules: Object,
    propParam: Object
  },
  components: {FortenUpload, sunMenu, customAnchor},
  computed: {

  }
}
</script>
<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
<style lang="scss" scopped>
  .container {
    width: 100%;
    height: 100%;
  }
  .ext-select-example {
    width: 500px !important;
  }

</style>
